import request from '/@/utils/request';

export function getTemplateList(query:Object) {
    return request({
        url: '/templates/list',
        method: 'get',
        params:query
    })
}
export function rebuildTemplatetable(tableID:any) {
    return request({
        url: '/templates/rebuildtable/' + tableID,
        method: 'post',
    })
}
export function orgtree() {
    return request({
        url: '/source/orgtree',
        method: 'GET',
    })
}
export function buildWithDing(dingcode:any) {
    return request({
        url: '/api/dingtalk/buildwithding/'+dingcode,
        method: 'get',
    })
}

export function addTemplate(data:Object) {
    return request({
        url: '/templates/add',
        method: 'post',
        data:data
    })
}
export function GetTemplateTable(id:any) {
    return request({
        url: '/template/'+id+'/tables',
        method: 'get',
    })
}export function deleteTemplate(id:any) {
    return request({
        url: '/templates/delete/'+id,
        method: 'delete',
    })
}
export function getTemplateInfo(code:any) {
    return request({
        url: '/templates/info/'+code,
        method: 'get',
    })
}
export function getSetTemplateInfo(code:any) {
    return request({
        url: '/templates/info/'+code,
        method: 'get',
        params:{type:'set'}
    })
}

export function updateTemplate(data:Object) {
    return request({
        url: '/templates/update/base',
        method: 'put',
        data:data
    })
}


export function editTemplateTable(data:Object) {
    return request({
        url: '/templates/update/table',
        method: 'put',
        data:data
    })
}

export function listDatatype() {
    return request({
        url: '/source/datatype/list',
        method: 'get'
    })
}

export function getRightList(tid: number) {
    return request({
        url: '/right/list/' + tid,
        method: 'get'
    })
}

export function editRight(tid: number, data: any) {
    return request({
        url: '/right/edit/' + tid,
        method: 'put',
        data: data
    })
}
export function resetRight(tid: number, data: any) {
    return request({
        url: '/right/reset/' + tid,
        method: 'put',
        data: data
    })
}

export function deleteRight(tid: any) {
    return request({
        url: '/right/delete',
        method: 'delete',
        data: tid
    })
}

export function GetTable(table: any) {
    return request({
        url: '/templates/gettable/' + table,
        method: 'get',
    })
}
export function getRole() {
    return request({
        url: '/system/role/list?pageSize=1000' ,
        method: 'get',
    })
}

export function getDatasource() {
    return request({
        url: '/source/datasource',
        method: 'get'
    })
}

